home *** CD-ROM | disk | FTP | other *** search
- *******************************************************************************
- * PROGRAM: Getflts.wfm
- *
- * WRITTEN BY: Borland Samples Group
- *
- * DATE: 5/93
- *
- * UPDATED: 3/94
- *
- * REVISION: $Revision: 1.20 $
- *
- * VERSION: dBASE FOR WINDOWS 5.0
- *
- * DESCRIPTION: This is a form called from Equipmnt.wfm that brings up a
- * dialog which allows selecting AirBorland flights based on
- * their origin, destination, and departure date. This form
- * has two listboxes -- originList and destList, and one
- * spinbox -- dateSpin. It also has Ok and Cancel buttons
- * that respectively allow the selections to be saved or
- * ignored.
- *
- *
- * PARAMETERS: None
- *
- * CALLS: Buttons.cc (Custom controls file)
- * Equipmnt.qbe (View of tables)
- *
- * USAGE: SET PROCEDURE TO GETFLTS.WFM
- * LOCAL F
- * F = NEW GETFLTS()
- * F.READMODAL()
- *
- *******************************************************************************
- #include <Messdlg.h>
- #include "Equipmnt.h"
- set ldCheck off
-
- ** END HEADER -- do not remove this line*
- * Generated on 06/01/94
- *
- LOCAL f
- f = NEW GETFLTSFORM()
- f.Open()
-
- CLASS GETFLTSFORM OF FORM
- Set Procedure to BUTTONS.CC Additive
- this.Height = 17.61
- this.HelpFile = ""
- this.HelpId = ""
- this.Text = "Flight Selection"
- this.OnOpen = CLASS::ONOPEN
- this.OnClose = CLASS::ONCLOSE
- this.OnSelection = CLASS::ONSELECTION
- this.ColorNormal = "N/0XFFFF80"
- this.MousePointer = 1
- this.Width = 71.26
- this.Top = 2.20
- this.Left = 17.16
-
- DEFINE IMAGE LOGOIMAGE OF THIS;
- PROPERTY;
- Height 5.78,;
- Alignment 2,;
- DataSource "FILE AIRBRLN2.BMP",;
- Width 58.07,;
- Top 0.00,;
- Left 6.60
-
- DEFINE TEXT ORIGTEXT OF THIS;
- PROPERTY;
- Height 1.32,;
- Text "Origin",;
- ColorNormal "N/0XFFFF80",;
- Border .F.,;
- Width 19.80,;
- Top 5.78,;
- FontSize 10.00,;
- Left 1.32
-
- DEFINE LISTBOX ORIGINLIST OF THIS;
- PROPERTY;
- Height 6.75,;
- Value "",;
- ColorNormal "N/W",;
- ColorHighLight "W+/B",;
- ID 800,;
- Width 20.46,;
- Top 7.09,;
- FontSize 11.25,;
- Left 0.99
-
- DEFINE TEXT DESTTEXT OF THIS;
- PROPERTY;
- Height 1.32,;
- Text "Destination",;
- ColorNormal "N/0XFFFF80",;
- Border .F.,;
- Width 19.80,;
- Top 5.78,;
- FontSize 10.00,;
- Left 27.71
-
- DEFINE LISTBOX DESTLIST OF THIS;
- PROPERTY;
- Height 6.75,;
- Value "",;
- ColorNormal "N/W",;
- ColorHighLight "W+/B",;
- ID 800,;
- Width 20.46,;
- Top 7.09,;
- FontSize 11.25,;
- Left 27.38
-
- DEFINE TEXT DATETEXT OF THIS;
- PROPERTY;
- Height 1.32,;
- Text "Date",;
- ColorNormal "N/0XFFFF80",;
- Border .F.,;
- Width 14.52,;
- Top 5.78,;
- FontSize 10.00,;
- Left 52.79
-
- DEFINE SPINBOX DATESPIN OF THIS;
- PROPERTY;
- Height 1.32,;
- Function "J",;
- ColorNormal "N/W",;
- Border .T.,;
- ColorHighLight "W+/B",;
- Width 17.82,;
- Top 7.16,;
- FontSize 11.25,;
- Left 52.79,;
- Rangemin {01/01/90},;
- Rangemax {01/01/94},;
- Value {01/01/92}
-
- DEFINE OKBUTTON GETFLTSOKBUTTON OF THIS;
- PROPERTY;
- Height 1.50,;
- Width 14.11,;
- Top 14.87,;
- Left 42.23
-
- DEFINE CANCELBUTTON GETFLTSCANCELBUTTON OF THIS;
- PROPERTY;
- OnClick .F.,; && OnSelection takes care of this
- Height 1.50,;
- Group .F.,;
- ID 0,;
- Width 14.11,;
- Top 14.87,;
- Left 56.75
-
- *******************************************************************************
- procedure OnOpen
- *******************************************************************************
- set procedure to program(1) additive && for functions located after class
- set procedure to Sampproc additive && for FormatStr function
-
- if type("originAr") = "U"
-
- public originAr,destAr && if called stand alone, create vars
- local curRecCnt
- private tagName
-
- this.standAlone = .t.
- this.view = "Equipmnt.qbe"
- *** make arrays of unique origins and destinations
- select flights
- tagName = field(2) + "UN"
- set order to &tagName && origin unique
- count to curRecCnt && count of unique origins -- for declaring array
-
- declare originAr[curRecCnt,1]
- declare destAr[curRecCnt,1]
-
- copy to array originAr field origin
- tagName = field(3) + "UN"
- set order to &tagName && destination unique
- count to curRecCnt && count of unique destinations -- for declaring array
- copy to array destAr field dest
- tagName = field(1)
- set order to &tagName && don't need the index for a while
- go top
- else
- this.standAlone = .f.
- endif
- this.originList.dataSource = "Array originAr"
- this.destList.dataSource = "Array destAr"
- this.dateSpin.value = flights->date
-
- *******************************************************************************
- procedure OnClose
- *******************************************************************************
- if form.standAlone && if not called from equipmnt.wfm
- release originAr, destAr
- endif
- close procedure Buttons.cc, Sampproc.prg, program(1)
-
-
- *******************************************************************************
- procedure OnSelection (controlId)
- *******************************************************************************
- private originT, destT, dateT, filter, planeT, curTable, tryAgain, tagName
-
- tryAgain = .f.
- *** if Cancel wasn't selected and if not running standalone
- if controlId <> 0
- * get the selected origin, destination
- originT = ALLTRIM(form.originList.value)
- destT = ALLTRIM(form.destList.value)
- dateT = form.dateSpin.value
- filter = ""
- *** longer, but looks cleaner with IF instead of IIF()
- if .not. empty(originT)
- filter = FormatStr("origin = %1", AddQuotes(originT))
- endif
- if .not. empty(destT)
- if .not. empty(filter)
- filter = FormatStr("%1 .and. dest = %2", filter, AddQuotes(destT))
- else
- filter = FormatStr("dest = %1", AddQuotes(destT))
- endif
- endif
- if .not. empty(dateT)
- if .not. empty(filter)
- filter = FormatStr("%1 .and. date >= ctod(%2)", filter, AddQuotes(dtoc(dateT)))
- else
- filter = FormatStr("date >= ctod(%1)", AddQuotes(dtoc(dateT)))
- endif
- endif
- * Check filter in another area, so form doesn't get updated unnecessarily
- use dbf() in select() alias temp
- select temp
- set filter to &filter
- go top
- if eof() && no flights match the selections made
- if ConfirmationMessage(;
- FormatStr("There are no flights from %1 to %2 on or after %3."+;
- chr(13) +;
- "Would you like to select another set of flights?",;
- originT, destT, dtoc(dateT)),;
- "Confirmation") = YES
- tryAgain = .t. && flag to specify that form stays open
- endif
- select flights
- else
- select flights
- set filter to &filter
- go top
- do case
- case .not. empty(originT) && if an origin was specified, index on
- && origin, and look for selected origin
- tagName = field(2)
- set order to &tagName && tag origin
- seek originT
- case .not. empty(destT) && otherwise, if a destination was
- tagName = field(3) && specified, index on that, and seek.
- set order to &tagName && tag dest
- seek destT
-
- otherwise && index on origin if no selection was
- tagName = field(2)
- set order to &tagName && made, and go to the top of the database
- go top
- endcase
- endif
- use in temp
- endif
- if .not. tryAgain
- form.Close()
- endif
-
- ENDCLASS
-
- *******************************************************************************
- function AddQuotes( string )
-
- * Add quotes to the parameter string. This function is used when combining
- * several strings and macrosubstituting (&) the resulting string
- *******************************************************************************
- return "'" + string + "'"
-
-
-
-